Skip to content

completed comp coding - 1#1355

Open
yashhh-23 wants to merge 1 commit into
super30admin:masterfrom
yashhh-23:master
Open

completed comp coding - 1#1355
yashhh-23 wants to merge 1 commit into
super30admin:masterfrom
yashhh-23:master

Conversation

@yashhh-23

Copy link
Copy Markdown

No description provided.

@super30admin

Copy link
Copy Markdown
Owner

Interview Problem: Find Missing Number in a sorted array (Problem1.java)

Strengths:

  • Correct binary search approach for finding the missing number
  • Proper use of loop termination condition (R - L) > 1
  • Correct handling of index comparisons

Areas for Improvement:

  1. Critical Bug: Typo in method name - searrch (three r's) vs search (called in main). This causes a compilation error.
  2. Formatting: Code lacks proper indentation and spacing, making it harder to read.
  3. Descriptive Names: Variable names like L, R, mid are acceptable but could be more descriptive (e.g., left, right).
  4. Comments: No comments explaining the logic, which would help understanding.
  5. Input Flexibility: Unlike the reference solution, this hardcodes the test array. Consider making it more flexible.

Recommended Fix:
Rename searrch to search to fix the compilation error.

VERDICT: NEEDS_IMPROVEMENT


Interview Problem: Design Min Heap

  1. Wrong Problem: The submitted solution solves a different problem (finding missing number in sorted array) rather than implementing a Min Heap as specified in the problem statement.

  2. Syntax Errors: The function is named searrch but called as search in main, which would cause a compilation error.

  3. Missing Required Operations: The problem requires implementing getMin(), extractMin(), and insert() operations for a Min Heap - none of which are present in this solution.

  4. No Heap Implementation: There's no heap array, no parent/child index calculations, no heapify logic, or any of the core Min Heap operations.

  5. What to Do: To improve, the student needs to:

    • Read the problem carefully and understand what is being asked
    • Implement a complete binary tree structure using an array
    • Implement helper methods for parent, left child, right child indices
    • Implement the insert() method with upward bubbling (sift-up)
    • Implement the extractMin() method with downward bubbling (sift-down/heapify)
    • Include proper error handling for edge cases (empty heap, full heap)

VERDICT: NEEDS_IMPROVEMENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants